<template>
  <div class="mod-config">
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;">
<!--      <el-table-column
        label="选中"
        type="selection"
        header-align="center"
        align="center"
        width="50">
      </el-table-column>-->
      <el-table-column
        type="index"
        label="序号"
        header-align="center"
        align="center"
        width="50">
      </el-table-column>
      <el-table-column
        prop="yaoCaiName"
        header-align="center"
        align="center"
        label="药材名称">
      </el-table-column>

      <el-table-column
        prop="createByName"
        header-align="center"
        align="center"
        label="报价人">
      </el-table-column>
      <el-table-column
        prop="baoJiaRenPhone"
        header-align="center"
        align="center"
        label="联系电话">
      </el-table-column>
      <el-table-column
        prop="woDeBaoJia"
        header-align="center"
        align="center"
        label="报价">
      </el-table-column>
      <el-table-column
        prop="gongYingShuLiang"
        header-align="center"
        align="center"
        label="供应数量">
      </el-table-column>
      <el-table-column
        prop="kuCunDi"
        header-align="center"
        align="center"
        label="库存地">
      </el-table-column>

      <el-table-column
        prop="caiGouRenName"
        header-align="center"
        align="center"
        label="采购人">
      </el-table-column>
      <el-table-column
        prop="caiGouRenPhone"
        header-align="center"
        align="center"
        label="采购人联系方式">
      </el-table-column>
      <el-table-column
        prop="createTime"
        header-align="center"
        align="center"
        label="报价时间">
      </el-table-column>

      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small"
                     @click="infoHandle(scope.row.id)"><i class="el-icon-edit"></i>查看详情</el-button>
          <!--                    <el-button type="text" size="small"
                                         @click="addOrUpdateHandle(scope.row.id)"><i class="el-icon-edit"></i>修改</el-button>
                              <el-button type="text" size="small"
                                         @click="deleteHandle(scope.row.id)"><i class="el-icon-delete"></i>删除</el-button>-->
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>

    <!-- 弹窗, 新增 / 修改 -->
    <el-dialog title="采购报价" :visible.sync="infoVisible" :modal-append-to-body="false">
      <div class="mod-config">
        <el-row>
          <div class="el-descriptions__title custom-title">采购详情</div>
        </el-row>
        <el-row :gutter="0" style="display: flex">
          <el-col :span="10" style="align-items: stretch;margin-right: 16px;">
            <img class="devImg" v-if="caiGouInfoList.yaoCaiTuPian" fit="fill" style="width: 100%;height: 330px" :src="this.$http.adornUrl('/api-file/file/view/file?fileId='+ this.caiGouInfoList.yaoCaiTuPian) ">
            <img class="devImg" v-else style="width: 100%;height: 330px" src="../../../../static/img/zwtp.png">
            <el-descriptions :column="1"   :colon="false" content-class-name="my-content">
              <el-descriptions-item label="">{{this.caiGouInfoList.yaoCaiMingCheng}}</el-descriptions-item>
            </el-descriptions>
            <p style="text-align: center;font-size: 14px">发布时间:{{this.caiGouInfoList.faBuShiJian}}</p>
          </el-col>
          <el-col :span="10">
            <el-descriptions :column="1" label-class-name="myLableClassName" >
              <el-descriptions-item label="规格">{{this.caiGouInfoList.guiGe}}</el-descriptions-item>
              <el-descriptions-item label="药材产地">{{this.caiGouInfoList.yaoCaiChanDi}}</el-descriptions-item>
              <el-descriptions-item label="企业">{{this.caiGouInfoList.qiYe}}</el-descriptions-item>
              <el-descriptions-item label="可供票据">{{this.caiGouInfoList.piaoJu}}</el-descriptions-item>
              <el-descriptions-item label="资质标准">{{this.caiGouInfoList.ziZhiBiaoZhun}}</el-descriptions-item>
              <el-descriptions-item label="质量标准">{{this.caiGouInfoList.zhiLiangBiaoZhun}}</el-descriptions-item>
              <el-descriptions-item label="付款方式">{{this.caiGouInfoList.fuKuanFangShi}}</el-descriptions-item>
              <el-descriptions-item label="联系人">{{this.caiGouInfoList.lianXiRen}}</el-descriptions-item>
              <el-descriptions-item label="联系电话">{{this.caiGouInfoList.lianXiDianHua}}</el-descriptions-item>
              <el-descriptions-item label="交货地">{{this.caiGouInfoList.jiaoHuoDiZhi}}</el-descriptions-item>
            </el-descriptions>
          </el-col>
          <el-col :span="4">
            <p style="text-align: left;font-size: 18px;font-weight:bold;color: red">需求量：{{this.caiGouInfoList.xuQiuLiang}}公斤</p>
            <p style="text-align: left;font-size: 20px;font-weight:bold;color: #00a2d4">{{this.caiGouInfoList.baoJiaRenShu}}</p>
            <p style="text-align: left;font-size: 20px;font-weight:bold;color: #00a2d4">{{this.caiGouInfoList.shiFouShangJia}}</p>
          </el-col>
        </el-row>
        <el-row>
          <div class="el-descriptions__title custom-title">报价详情</div>
        </el-row>
        <el-row>
          <el-col :span="12">
            <p>
              <span class="customspan">我的报价：</span>
              {{this.infoList.woDeBaoJia}}</p>
          </el-col>
          <el-col :span="12">
            <P>
              <span  class="customspan">资质标准：</span>
              <span>{{this.infoList.ziZhiBiaoZhun}}</span>
            </P>
            <!--                  <img class=".custom-radio .el-radio__input.is-checked .el-radio__inner" src="./duigou.jpg">-->
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <p>
              <span class="customspan">供应数量：</span>
              <span>{{this.infoList.gongYingShuLiang}}</span>
            </p>
          </el-col>
          <el-col :span="12">
            <span class="customspan">寄样：</span>
            <span>{{this.infoList.jiYang}}</span>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <p>
              <span class="customspan">库存地：</span>
              <span>{{this.infoList.kuCunDi}}</span>
            </p>
          </el-col>
          <el-col :span="12">
            <span class="customspan">付款：</span>
            <span>
                   {{this.infoList.fuKuan}}
                  </span>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <p>
              <span class="customspan">药材产地：</span>
              <span>{{this.infoList.yaoCaiChanDi}}</span>
            </p>
          </el-col>
          <el-col :span="12">
            <span class="customspan">包装：</span>
            <span>
                   {{this.infoList.baoZhuang}}
                  </span>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <p>
              <span class="customspan">质量标准：</span>
              <span>{{this.infoList.zhiLiangBiaoZhun}}</span>
            </p>
          </el-col>
          <el-col :span="12">
            <span  class="customspan">可供票据：</span>
            <span>
                  {{this.infoList.piaoJu}}
                  </span>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <p>
              <span class="customspan">报价时间：</span>
              <span>{{this.infoList.createTime}}</span>
            </p>
          </el-col>
          <el-col :span="12">
            <span class="customspan">货源说明：</span>
            <span>
                  {{this.infoList.huoYuanShuoMing}}
                  </span>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <p>
              <span class="customspan">药材图片：</span>
              <img v-if="caiGouInfoList.yaoCaiTuPian" width="150px" height="150px"  :src="this.$http.adornUrl('/api-file/file/view/file?fileId='+ this.caiGouInfoList.yaoCaiTuPian) ">
            </p>
          </el-col>
        </el-row>

        <!--                <el-descriptions :column="2" :colon="false" title="设备信息">-->
        <!--                            <el-descriptions-item label="我的报价">{{this.infoList.woDeBaoJia}}</el-descriptions-item>-->
        <!--                            <el-descriptions-item label="被报价采购id">{{this.infoList.beiBaoJiaCaiGouID}}</el-descriptions-item>-->
        <!--                            <el-descriptions-item label="供应数量">{{this.infoList.gongYingShuLiang}}</el-descriptions-item>-->
        <!--                            <el-descriptions-item label="库存地">{{this.infoList.kuCunDi}}</el-descriptions-item>-->
        <!--                            <el-descriptions-item label="药材产地">{{this.infoList.yaoCaiChanDi}}</el-descriptions-item>-->
        <!--                            <el-descriptions-item label="质量标准">{{this.infoList.zhiLiangBiaoZhun}}</el-descriptions-item>-->
        <!--                            <el-descriptions-item label="药材图片">{{this.infoList.yaoCaiTuPian}}</el-descriptions-item>-->
        <!--                            <el-descriptions-item label="票据">{{this.infoList.piaoJu}}</el-descriptions-item>-->
        <!--                            <el-descriptions-item label="资质标准">{{this.infoList.ziZhiBiaoZhun}}</el-descriptions-item>-->
        <!--                            <el-descriptions-item label="寄样">{{this.infoList.jiYang}}</el-descriptions-item>-->
        <!--                            <el-descriptions-item label="付款">{{this.infoList.fuKuan}}</el-descriptions-item>-->
        <!--                            <el-descriptions-item label="包装">{{this.infoList.baoZhuang}}</el-descriptions-item>-->
        <!--                            <el-descriptions-item label="货源说明">{{this.infoList.huoYuanShuoMing}}</el-descriptions-item>-->
        <!--                            <el-descriptions-item label="关联用户">{{this.infoList.guanLianYongHu}}</el-descriptions-item>-->
        <!--                </el-descriptions>-->
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="qxinfo()">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      radio: 1,
      dataForm: {
        woDeBaoJia:'',
        beiBaoJiaCaiGouID:'',
        gongYingShuLiang:'',
        kuCunDi:'',
        yaoCaiChanDi:'',
        zhiLiangBiaoZhun:'',
        yaoCaiTuPian:'',
        piaoJu:'',
        ziZhiBiaoZhun:'',
        jiYang:'',
        fuKuan:'',
        baoZhuang:'',
        huoYuanShuoMing:'',
        guanLianYongHu:'',
      },

      dataRule: {
        woDeBaoJia: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],

        gongYingShuLiang: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],
        kuCunDi: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],
        yaoCaiChanDi: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],
        zhiLiangBiaoZhun: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],
        yaoCaiTuPian: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],
        piaoJu: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],
        ziZhiBiaoZhun: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],
        jiYang: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],
        fuKuan: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],
        baoZhuang: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],
        huoYuanShuoMing: [
          {required: true, message: '不能为空', trigger: 'blur'}
        ],

      },
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      dataListSelections: [],
      addOrUpdateVisible: false,

      infoList:[],
      caiGouInfoList:[],
      infoLoading: false,
      infoVisible: false,
      beiBaoJiaCaiGouID:''
    }
  },

  activated() {
    console.log("ddddddddddddddddddddddddddddddd")

  },
  methods: {
    init(id){

    this.beiBaoJiaCaiGouID=id
    this.getDataList()

    },
    getDataList(pageIndex) {
      if (pageIndex) {
        this.pageIndex = pageIndex
      }
      this.dataListLoading = true

      this.$http({
        url: this.$http.adornUrl('/api-trading/woDeXiaoDian/woDeXiaoDianShouDaoBaoJia/getListByCaiGouId'),
        method: 'get',
        params: this.$http.adornParams({
          'page': this.pageIndex,
          'limit': this.pageSize,
          'beiBaoJiaCaiGouID':this.beiBaoJiaCaiGouID
        })
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.dataList = data.data.list
          this.totalPage = Number(data.data.totalCount)
        } else {
          this.dataList = []
          this.totalPage = 0
        }
        this.dataListLoading = false
      })
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },
    // 多选
    selectionChangeHandle(val) {
      this.dataListSelections = val
    },
    qx() {
      this.addOrUpdateVisible = false;

    },

    qxinfo() {
      this.infoVisible = false;

    },
    // 新增 / 修改
    infoHandle(id) {
      this.infoVisible = true;
      this.infoList=[];
      this.caiGouInfoList=[];
      this.$http({
        url: this.$http.adornUrl(`/api-trading/woDeXiaoDian/woDeXiaoDianShouDaoBaoJia/getById`),
        method: 'get',
        params: this.$http.adornParams({"id":id})
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.infoList=data.data.baoJiaInfo;
          this.caiGouInfoList=data.data.caiGouInfo
        }
      })
    },


  }
}
</script>
<style>
.imgBox {
  border: 1px solid #ebeef5;
  border-left: none;
  width: 100%;
  height: 100%;
  position: relative;
  .devImg {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    height: auto;
    max-height: 100%;
    padding: 12px 10px;
  }
}
.my-content{
  display: flex;
  justify-content: center; /* 水平居中 */
  align-items: center; /* 垂直居中 */
//height: 100vh; /* 设置容器高度为视口高度 */
  align-items:center;text-align: center;
  font-weight:bold;font-size: 18px;

}
.custom-title{
  margin-bottom: 20px;
  font-size: 20px;
//margin-top: 20px;
}
.myLableClassName {
  color: rgb(19 35 29 / 77%);text-align:right;font-weight:bold;font-size: 16px;
}
.customspan{
  font-weight: bold;
  font-size: 16px;
}
//-------
/*.custom-radio .el-radio__input {
  position: absolute;
  right: 0;
  bottom: 0;
}

.custom-radio .el-radio__label {
  padding-left: 20px; !* 根据对勾大小和需要留出的空间调整 *!
  height: 20px; !* 根据实际需要调整 *!
  display: inline-block;
  line-height: 20px; !* 使元素垂直居中 *!
}*/

.custom-radio .el-radio__input.is-checked .el-radio__inner {
  background-color: #409EFF;
  border-color: #409EFF;
}

.custom-radio .el-radio__input.is-checked .el-radio__inner::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translate(-50%, 50%);
  width: 14px;
  height: 14px;
  background-color: #fff;
  border-radius: 100%;
}

.custom-radio .el-radio__label {
  padding-left: 10px;
}
</style>
